package org.lex.jadfront.core;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;

public class ProcessReader implements Runnable {
	private final Reader reader;
	private final PrintWriter writer;

	public ProcessReader(InputStream in) {
		this(in, new PrintWriter(System.out));
	}

	public ProcessReader(InputStream in, OutputStream out) {
		this(in, new PrintWriter(out));
	}

	public ProcessReader(InputStream in, PrintWriter out) {
		this.reader = new InputStreamReader(in);
		this.writer = out;
	}

	public void run() {
		int ch = -1;
		try {
			while (-1 != (ch = reader.read())) {
				writer.print((char) ch);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
